<?php
	extract($_REQUEST, EXTR_PREFIX_ALL|EXTR_REFS, 'v');
	$car=$v_car;
	if(isset($v_grp)){$grp=$v_grp;}
	
		$cart=$car;
		$ssid = $_SESSION['id'];
		//Finding if Account Belongs to any Distributor Group
        	$looking="select * from distributor_groups where distributor='$ssid'";
		$lookingres=mysql_query($looking,$db);
		$rl = mysql_fetch_array($lookingres);
		$grouping=$rl['group'];
		$promoname="";
            	if (isset($grp)){
			$distributor=$ssid;
			foreach($grp as $val){                      
	                        $catval = strtolower($val);
        	                $quanval = 1;
						
						//check if there is a same product ordered under same ID
						$chk="select * from shoplist_dist where sessionid='$ssid' and LOWER(catNo) like '$catval'";
						$chk_res=mysql_query($chk,$db);
						$chk_rw=mysql_num_rows($chk_res);
						if ($chk_rw>0){
							$upd="update shoplist_dist set quantity = quantity + $quanval where sessionid='$ssid' and LOWER(catNo) like '$catval'";
							$ins_res=mysql_query($upd,$db);
						}else{
							
							/****************************************************************/
							/* check pname, price, dbNo, size/unit, supplier, promotioncode */
							/*                                                              */
							/****************************************************************/
							
							switch ($catval){
								default:
									//search antibodies
									$sql="select * from products where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 1;
										break;
									}                                          

                                                //search siRNA Lentivirus
                                                $sql="select * from prodsirna where LOWER(catNo) like '$catval'";
                                                $result=mysql_query($sql,$db);
                                                $row=mysql_num_rows($result);
                                                if ($row>0){
													$csnn=9;
                                                    $dbNo = 2;
                                                    break;
                                                }                                            

                                                //search Lentivirus
                                                $sql="select * from prodlenti where LOWER(catNo) like '$catval'";
                                                $result=mysql_query($sql,$db);
                                                $row=mysql_num_rows($result);
                                                if ($row>0){
													$csnn=10;
                                                    $dbNo = 3;
                                                    break;
                                                }                                            

                                                //search Adenovirus
                                                $sql="select * from prodadenovirus where LOWER(catNo) like '$catval'";
                                                $result=mysql_query($sql,$db);
                                                $row=mysql_num_rows($result);
                                                if ($row>0){
                                                    $dbNo = 4;
													$csnn=11;
                                                    break;
                                                }
								
									//search PCR
									$sql="select * from prodpcr where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 5;
										break;
									}
								
									//search Transfection Reagent
									$sql="select * from prodtrans where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 6;
										break;
									}
								
									//search Viral Expression and iLenti RNAi expression
									$sql="select * from prodviralexp where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 7;
										break;
									}
								
									//search Secondary Antibodies
									$sql="select * from prodsecondanti where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 8;
										break;
									}
								
									//TABLE DOESN'T EXIST ANY MORE
									//search Custom iLenti siRNA
									//$sql="select * from prodrna where LOWER(catNo) like '$catval'";
									//$result=mysql_query($sql,$db);
									//$row=mysql_num_rows($result);
									//if ($row>0){
									//	$dbNo = 9;
									//	break;
									//}
								
									//search DNA/Protein Marker
									$sql="select * from prodmarkers where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 10;
										break;
									}
								
									//search Western Blot
									$sql="select * from prodwesternblot where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 11;
										break;
									}
								
									//search Cell Lysate
									$sql="select * from prodlysates where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 12;
										break;
									}
								
									//search Cell Immortalization
									$sql="select * from prodcellimmort where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 13;
										break;
									}
								
									//search DNA Purification
									$sql="select * from proddnapure where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 14;
										break;
									}
								
									//search Custom Services
									$sql="select * from custom_service where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 15;
										break;
									}
								
									//search Chemicals
									$sql="select * from prodbiochems where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 16;
										break;
									}
								
									//search Antibiotics
									$sql="select * from prodantibiotics where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 17;
										break;
									}
								
									//search Immortalized Primary Cells
									$sql="select * from prodihc where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 18;
										break;
									}
								
									//search miRNA cDNA Synthesis Kit
									$sql="select * from prodcDNAmirna where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 19;
										break;
									}
								
									//search miRNA Expression Vectors
									$sql="select * from premade_mirna_exp where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 26;
										break;
									}
								
									//search miRNA 3'UTR Lenti-Reporter Vectors
									$sql="select * from mirna_validator where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 27;
										break;
									}
								
									//search Individual miRNA Primers Sets
									$sql="select * from mirna_primers_sets where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 28;
										break;
									}
								
									//search Stem Cell Culture
									$sql="select * from prod_cell_culture where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 30; 
										break;
									}
									
									//iPSC Lentivirus
									$sql="select * from prodstemcell where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 31; 
										break;
									}
									
									//iPSC Recombinant Proteins
									$sql="select * from prodprotein where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 32; 
										break;
									}
									
									//iPSC Plasmids
									$sql="select * from prodipscplasmid where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 33; 
										break;
									}
									
									//iPSC Small Molecules
									$sql="select * from prodsmallmolecule where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 34; 
										break;
									}
									
									//iPSC Feeder cell
									$sql="select * from prod_feeder_cell where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 35; 
										break;
									}
									
									//iPSC Growth Factors
									$sql="select * from prod_growth_factor where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 36; 
										break;
									}
									
									//search Primary Cells
									$sql="select * from prod_primary_cells where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 43; 
										break;
									}
								
									//search Protein Purification
									$sql="select * from prodproteinpure where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 44; 
										break;
									}
								
									//search Stable Cell Lines
									$sql="select * from prod_ipsc_cells where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 45; 
										break;
									}
									
									//search iPSC Char. Kits
					                $sql="select * from prodstemcellkits where LOWER(catNo) like '$catval'";
                                	$result=mysql_query($sql,$db);
                                	$row=mysql_num_rows($result);
                                	if ($row>0){
                                	    $dbNo = 46; 
                                	    break;
                                	}
									
									//search miRNA Array Profiling Kits
                                	$sql="select * from prodmirnaarray where LOWER(catNo) like '$catval'";
                                	$result=mysql_query($sql,$db);
                                	$row=mysql_num_rows($result);
                                	if ($row>0){
                                	    $dbNo = 47; 
                                	    break;
                                	}
									
									//search Stable Cell Lines
                                	$sql="select * from prod_cell_lines where LOWER(catNo) like '$catval'";
                                	$result=mysql_query($sql,$db);
                                	$row=mysql_num_rows($result);
                                	if ($row>0){
                                	    $dbNo = 48; 
				                        break;
                                    }

									//search 3'UTR Cell Lines
                        			$sql="select * from prod_stable_cells where LOWER(catNo) like '$catval'";
					                $result=mysql_query($sql,$db);
					                $row=mysql_num_rows($result);
                                    if ($row>0){
                                        $dbNo = 49; 
                                        break;
                                    }
									
									//search Diagnostic Kits
					                $sql="select * from prod_diagnostic_kits where LOWER(catNo) like '$catval'";
					                $result=mysql_query($sql,$db);
                                    $row=mysql_num_rows($result);
				                    if ($row>0){
                                	    $dbNo = 50; 
                                	    break;
                                	}
									
									//search Diagnostic Kits
					                $sql="select * from prod_equipment where LOWER(catNo) like '$catval'";
					                $result=mysql_query($sql,$db);
                                    $row=mysql_num_rows($result);
				                    if ($row>0){
                                	    $dbNo = 51; 
                                	    break;
                                	}
									
									//search Diagnostic Kits
					                $sql="select * from prodProteinVector where LOWER(catNo) like '$catval'";
					                $result=mysql_query($sql,$db);
                                    $row=mysql_num_rows($result);
				                    if ($row>0){
                                	    $dbNo = 53; 
                                	    $csnn = 53;
                                	    break;
                                	}
									
									//search ORF Vectors
					                $sql="select * from prodORFVector where LOWER(catNo) like '$catval'";
					                $result=mysql_query($sql,$db);
                                    $row=mysql_num_rows($result);
				                    if ($row>0){
                                	    $dbNo = 54;
                                	    $csnn = 54; 
                                	    break;
                                	}
												
									//search Other Products
									$sql="select * from prodothers where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 99;
										break;
									}
							}
							
							if ($row > 0){
								$r = mysql_fetch_array($result);
											//If Premade siRNA, Adeno or Lenti maintains csn=8
											if($dbNo==12){
												$csnn = $r['csn'];
												if($csn<>23){
													$csnn=56;
												}
											}elseif($dbNo==32){
												$csnn = $r['csn'];
												if($csn<>30){
													$csnn=55;
												}
											}elseif($dbNo<>2&&$dbNo<>3&&$dbNo<>4&&$dbNo<>53&&$dbNo<>54){
                                            	$csnn = $r['csn'];
											}
                        		                    $ssnn = $r['ssn'];
                        		                    $dsnn = $r['dsn'];
                        		                    $pname = $r['pname'];
                        		                    $catalog = $r['catNo'];									
							    $testcatno = substr($catalog,0,1);
		                                            $orgprice = $r['price'];
											if($orgprice==0&&$dsnn=12288){
												$genename=str_replace("UTR Lenti-reporter-Luc Vector","",$pname);
												$genename=str_replace("UTR Lenti-reporter-GFP Vector","",$genename);
												$genename=substr_replace($genename,"",-7);
												$srchp = "select * from `3primeUTRsequenceProcess` where geneName like '$genename\n' order by totalNumber desc";
												$resp = mysql_query($srchp,$db);
												$rpr = mysql_fetch_array($resp);
												$orgprice = $rpr['price'];
										    }
                                            $inventory = $r['inventory'];
                                            $supplier = $r['supplier'];
											if (isset($r['size'])){
                                                $size = $r['size'];
                                            }elseif (isset ($r['quantity'])){
                                                $size = $r['quantity'];
                                            }else{
											}
											
												//find discounts for all products for distributors, individual discounts take priority over group discounts and specific discounts take priority over broad category discounts
												$find="select * from distributor_discounts where id_number='$distributor' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='$catalog'";
												$resulting=mysql_query($find,$db);
												$row7=mysql_num_rows($resulting);
												
												$find1="select * from distributor_discounts where id_number='$distributor' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='0'";
												$resulting1=mysql_query($find1,$db);
												$row1=mysql_num_rows($resulting1);
												
												$find2="select * from distributor_discounts where id_number='$distributor' and csn='$csnn' and ssn='$ssnn'and dsn='0' and catNo='0'";
												$resulting2=mysql_query($find2,$db);
												$row2=mysql_num_rows($resulting2);
												
												$find3="select * from distributor_discounts where id_number='$distributor' and csn='$csnn' and ssn='0'and dsn='0' and catNo='0'";
												$resulting3=mysql_query($find3,$db);
												$row3=mysql_num_rows($resulting3);
												
												$find4="select * from distributor_discounts where id_number='$distributor' and csn='0'";
												$resulting4=mysql_query($find4,$db);
												$row4=mysql_num_rows($resulting4);
												
												$find5="select * from distributor_group_discounts where group_number='$grouping' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='$catalog'";
												$resulting5=mysql_query($find5,$db);
												$row5=mysql_num_rows($resulting5);
												
												$find6="select * from distributor_group_discounts where group_number='$grouping' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='0'";
												$resulting6=mysql_query($find6,$db);
												$row6=mysql_num_rows($resulting6);
												
												$find8="select * from distributor_group_discounts where group_number='$grouping' and csn='$csnn' and ssn='$ssnn'and dsn='0' and catNo='0'";
												$resulting8=mysql_query($find8,$db);
												$row8=mysql_num_rows($resulting8);
												
												$find9="select * from distributor_group_discounts where group_number='$grouping' and csn='$csnn' and ssn='0'and dsn='0' and catNo='0'";
												$resulting9=mysql_query($find9,$db);
												$row9=mysql_num_rows($resulting9);
												
												$find10="select * from distributor_group_discounts where group_number='$grouping' and csn='0'";
												$resulting10=mysql_query($find10,$db);
												$row10=mysql_num_rows($resulting10);
												
												//For G*** Cat. No. Antibodies turns them into 'Tag Antibodes' Discount for Groups
												if($testcatno=='G' && $dbNo==1){
													$find35="select * from distributor_group_discounts where group_number='$grouping' and csn='17' and ssn='0'and dsn='0' and catNo='0'";
													$resulting35=mysql_query($find35,$db);
													$row35=mysql_num_rows($resulting35);
													
													$find36="select * from distributor_discounts where id_number='$distributor' and csn='17' and ssn='0'and dsn='0' and catNo='0'";
													$resulting36=mysql_query($find36,$db);
													$row36=mysql_num_rows($resulting36);
												}else{
													$row35=0;
													$row36=0;
												}
												
												$find44="select * from supplier_allowableAccounts where account='$distributor'";
												$resulting44=mysql_query($find44,$db);
												$row44=mysql_num_rows($resulting44);
												if($row44>0 && ($dbNo==1 || $dbNo==8)){
													$find33="select * from supplier_discounts where supplier like '%$supplier%'";
													$resulting33=mysql_query($find33,$db);
													$row33=mysql_num_rows($resulting33);
												}else{
													$row33=0;
												}
												
												if ($row7>0){
													$rf = mysql_fetch_array($resulting);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row5>0){
													$rf = mysql_fetch_array($resulting5);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row1>0){
													$rf = mysql_fetch_array($resulting1);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row6>0){
													$rf = mysql_fetch_array($resulting6);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row2>0){
													$rf = mysql_fetch_array($resulting2);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row8>0){
													$rf = mysql_fetch_array($resulting8);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row3>0){
													$rf = mysql_fetch_array($resulting3);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row9>0){
													$rf = mysql_fetch_array($resulting9);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row4>0){
													$rf = mysql_fetch_array($resulting4);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row10>0){
													$rf = mysql_fetch_array($resulting10);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row36>0){
													$rf = mysql_fetch_array($resulting36);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row35>0){
													$rf = mysql_fetch_array($resulting35);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row33>0){
													$rf = mysql_fetch_array($resulting33);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif($promoname<>""){
													//For Finding Promotion Code Discounts, only valid if no other discounts found first
													$findpromo1="select * from distributor_promo where promo_code='$promoname' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='$catalog'";
													$resultingpromo1=mysql_query($findpromo1,$db);
													$rowp1=mysql_num_rows($resultingpromo1);
													
													$findpromo2="select * from distributor_promo where promo_code='$promoname' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='0'";
													$resultingpromo2=mysql_query($findpromo2,$db);
													$rowp2=mysql_num_rows($resultingpromo2);
													
													$findpromo3="select * from distributor_promo where promo_code='$promoname' and csn='$csnn' and ssn='$ssnn' and dsn='0' and catNo='0'";
													$resultingpromo3=mysql_query($findpromo3,$db);
													$rowp3=mysql_num_rows($resultingpromo3);
													
													$findpromo4="select * from distributor_promo where promo_code='$promoname' and csn='$csnn' and ssn='0' and dsn='0' and catNo='0'";
													$resultingpromo4=mysql_query($findpromo4,$db);
													$rowp4=mysql_num_rows($resultingpromo4);
													
													$findpromo5="select * from distributor_promo where promo_code='$promoname' and csn='0';";
													$resultingpromo5=mysql_query($findpromo5,$db);
													$rowp5=mysql_num_rows($resultingpromo5);
													
													if($rowp1>0){
														$rf = mysql_fetch_array($resultingpromo1);
														$discountper=$rf['percentage_off'];
														$discountamt=$orgprice*$discountper;
														$price=$orgprice-$discountamt;
													}elseif($rowp2>0){
														$rf = mysql_fetch_array($resultingpromo2);
														$discountper=$rf['percentage_off'];
														$discountamt=$orgprice*$discountper;
														$price=$orgprice-$discountamt;
													}elseif($rowp3>0){
														$rf = mysql_fetch_array($resultingpromo3);
														$discountper=$rf['percentage_off'];
														$discountamt=$orgprice*$discountper;
														$price=$orgprice-$discountamt;
													}elseif($rowp4>0){
														$rf = mysql_fetch_array($resultingpromo4);
														$discountper=$rf['percentage_off'];
														$discountamt=$orgprice*$discountper;
														$price=$orgprice-$discountamt;
													}elseif($rowp5>0){
														$rf = mysql_fetch_array($resultingpromo5);
														$discountper=$rf['percentage_off'];
														$discountamt=$orgprice*$discountper;
														$price=$orgprice-$discountamt;
													}else{
														$discountper=0.0;
														$discountamt=0.00;
														$price=$orgprice;
													}
												}else{
													$discountper=0.0;
													$discountamt=0.00;
													$price=$orgprice;
												}
												//Find Shipping Conditions for Product
												$find="select * from distributor_shipping where csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='$catalog'";
												$resulting=mysql_query($find,$db);
												$row7=mysql_num_rows($resulting);
												
												$find1="select * from distributor_shipping where csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='0'";
												$resulting1=mysql_query($find1,$db);
												$row1=mysql_num_rows($resulting1);
												
												$find2="select * from distributor_shipping where csn='$csnn' and ssn='$ssnn' and dsn='0' and catNo='0'";
												$resulting2=mysql_query($find2,$db);
												$row2=mysql_num_rows($resulting2);
												
												$find3="select * from distributor_shipping where csn='$csnn' and ssn='0' and dsn='0' and catNo='0'";
												$resulting3=mysql_query($find3,$db);
												$row3=mysql_num_rows($resulting3);
												
												$find4="select * from distributor_shipping where csn='0'";
												$resulting4=mysql_query($find4,$db);
												$row4=mysql_num_rows($resulting4);
												
												if ($row7>0){
													$rf = mysql_fetch_array($resulting);
													$conditions=$rf['conditions'];
												}elseif ($row1>0){
													$rf = mysql_fetch_array($resulting1);
													$conditions=$rf['conditions'];
												}elseif ($row2>0){
													$rf = mysql_fetch_array($resulting2);
													$conditions=$rf['conditions'];
												}elseif ($row3>0){
													$rf = mysql_fetch_array($resulting3);
													$conditions=$rf['conditions'];
												}elseif ($row4>0){
													$rf = mysql_fetch_array($resulting4);
													$conditions=$rf['conditions'];
												}else{
													$conditions='N/A';
												}
                                            
                                        }else{
                                            echo "<script language=javascript>alert('One or more product(s) not found, rest of products added successfully.');</script>";
                                            break;
                                        }
                                        //Insert item into shopping cart
                                        $ins = "insert into shoplist_dist (catNo,csnNumber,ssnNumber,dsnNumber,dbNo,pname,sessionid,unit,org_price,discount_percent,discount_amount,price,quantity,supplier,shipping,inventory) 
                                        values ('$catalog',$csnn,$ssnn,$dsnn,'$dbNo','$pname','$ssid','$size','$orgprice','$discountper','$discountamt','$price','$quanval','$supplier','$conditions','$inventory')";
                                        $ins_res = mysql_query($ins,$db);
						}
					}
				}elseif(isset($v_catno)){
				$ssid = $_SESSION['id'];
				$distributor=$ssid;
                        	$catname = 'v_catno';
                        	$quanname = 'v_orderquan';
                        
        	                $catval = strtolower($$catname);
        	                $quanval = $$quanname;
						
						//check if there is a same product ordered under same ID
						$chk="select * from shoplist_dist where sessionid='$ssid' and LOWER(catNo) like '$catval'";
						$chk_res=mysql_query($chk,$db);
						$chk_rw=mysql_num_rows($chk_res);
						if ($chk_rw>0){
							$upd="update shoplist_dist set quantity = quantity + $quanval where sessionid='$ssid' and LOWER(catNo) like '$catval'";
							$ins_res=mysql_query($upd,$db);
						}else{
							/****************************************************************/
							/* check pname, price, dbNo, size/unit, supplier, promotioncode */
							/*                                                              */
							/****************************************************************/
							
							switch ($catval){
								default:
									//search antibodies
									$sql="select * from products where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 1;
										break;
									}                                           

                                                //search siRNA Lentivirus
                                                $sql="select * from prodsirna where LOWER(catNo) like '$catval'";
                                                $result=mysql_query($sql,$db);
                                                $row=mysql_num_rows($result);
                                                if ($row>0){
													$csnn=9;
                                                    $dbNo = 2;
                                                    break;
                                                }                                            

                                                //search Lentivirus
                                                $sql="select * from prodlenti where LOWER(catNo) like '$catval'";
                                                $result=mysql_query($sql,$db);
                                                $row=mysql_num_rows($result);
                                                if ($row>0){
													$csnn=10;
                                                    $dbNo = 3;
                                                    break;
                                                }                                            

                                                //search Adenovirus
                                                $sql="select * from prodadenovirus where LOWER(catNo) like '$catval'";
                                                $result=mysql_query($sql,$db);
                                                $row=mysql_num_rows($result);
                                                if ($row>0){
                                                    $dbNo = 4;
													$csnn=11;
                                                    break;
                                                }
								
									//search PCR
									$sql="select * from prodpcr where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 5;
										break;
									}
								
									//search Transfection Reagent
									$sql="select * from prodtrans where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 6;
										break;
									}
								
									//search Viral Expression and iLenti RNAi expression
									$sql="select * from prodviralexp where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 7;
										break;
									}
								
									//search Secondary Antibodies
									$sql="select * from prodsecondanti where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 8;
										break;
									}
								
									//TABLE DOESN'T EXIST ANY MORE
									//search Custom iLenti siRNA
									//$sql="select * from prodrna where LOWER(catNo) like '$catval'";
									//$result=mysql_query($sql,$db);
									//$row=mysql_num_rows($result);
									//if ($row>0){
									//	$dbNo = 9;
									//	break;
									//}
								
									//search DNA/Protein Marker
									$sql="select * from prodmarkers where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 10;
										break;
									}
								
									//search Western Blot
									$sql="select * from prodwesternblot where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 11;
										break;
									}
								
									//search Cell Lysate
									$sql="select * from prodlysates where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 12;
										break;
									}
								
									//search Cell Immortalization
									$sql="select * from prodcellimmort where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 13;
										break;
									}
								
									//search DNA Purification
									$sql="select * from proddnapure where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 14;
										break;
									}
								
									//search Custom Services
									$sql="select * from custom_service where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 15;
										break;
									}
								
									//search Chemicals
									$sql="select * from prodbiochems where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 16;
										break;
									}
								
									//search Antibiotics
									$sql="select * from prodantibiotics where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 17;
										break;
									}
								
									//search Immortalized Primary Cells
									$sql="select * from prodihc where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 18;
										break;
									}
								
									//search miRNA cDNA Synthesis Kit
									$sql="select * from prodcDNAmirna where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 19;
										break;
									}
								
									//search miRNA Expression Vectors
									$sql="select * from premade_mirna_exp where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 26;
										break;
									}
								
									//search miRNA 3'UTR Lenti-Reporter Vectors
									$sql="select * from mirna_validator where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 27;
										break;
									}
								
									//search Individual miRNA Primers Sets
									$sql="select * from mirna_primers_sets where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 28;
										break;
									}
								
									//search Stem Cell Culture
									$sql="select * from prod_cell_culture where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 30; 
										break;
									}
									
									//iPSC Lentivirus
									$sql="select * from prodstemcell where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 31; 
										break;
									}
									
									//iPSC Recombinant Proteins
									$sql="select * from prodprotein where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 32; 
										break;
									}
									
									//iPSC Plasmids
									$sql="select * from prodipscplasmid where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 33; 
										break;
									}
									
									//iPSC Small Molecules
									$sql="select * from prodsmallmolecule where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 34; 
										break;
									}
									
									//iPSC Feeder cell
									$sql="select * from prod_feeder_cell where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 35; 
										break;
									}
									
									//iPSC Growth Factors
									$sql="select * from prod_growth_factor where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 36; 
										break;
									}
									
									//search Primary Cells
									$sql="select * from prod_primary_cells where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 43; 
										break;
									}
								
									//search Protein Purification
									$sql="select * from prodproteinpure where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 44; 
										break;
									}
								
									//search Stable Cell Lines
									$sql="select * from prod_ipsc_cells where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 45; 
										break;
									}
									
									//search iPSC Char. Kits
                                    					$sql="select * from prodstemcellkits where LOWER(catNo) like '$catval'";
                                    					$result=mysql_query($sql,$db);
                                    					$row=mysql_num_rows($result);
                                    					if ($row>0){
                                    					    $dbNo = 46; 
                                   					    break;
                                    					}
									
									//search miRNA Array Profiling Kits
									    $sql="select * from prodmirnaarray where LOWER(catNo) like '$catval'";
									    $result=mysql_query($sql,$db);
									    $row=mysql_num_rows($result);
									    if ($row>0){
										$dbNo = 47; 
										break;
									    }
									
									//search Stable Cell Lines
									    $sql="select * from prod_cell_lines where LOWER(catNo) like '$catval'";
									    $result=mysql_query($sql,$db);
									    $row=mysql_num_rows($result);
										        if ($row>0){
										            $dbNo = 48; 
										            break;
										        }

									//search 3'UTR Cell Lines
									    $sql="select * from prod_stable_cells where LOWER(catNo) like '$catval'";
									    $result=mysql_query($sql,$db);
									    $row=mysql_num_rows($result);
										        if ($row>0){
										            $dbNo = 49; 
										            break;
										        }
									
									//search Diagnostic Kits
									    $sql="select * from prod_diagnostic_kits where LOWER(catNo) like '$catval'";
									    $result=mysql_query($sql,$db);
									    $row=mysql_num_rows($result);
										        if ($row>0){
										            $dbNo = 50; 
										            break;
										        }
									
									//search Diagnostic Kits
					                $sql="select * from prod_equipment where LOWER(catNo) like '$catval'";
					                $result=mysql_query($sql,$db);
                                    $row=mysql_num_rows($result);
				                    if ($row>0){
                                	    $dbNo = 51; 
                                	    break;
                                	}
									
									//search Diagnostic Kits
					                $sql="select * from prodProteinVector where LOWER(catNo) like '$catval'";
					                $result=mysql_query($sql,$db);
                                    $row=mysql_num_rows($result);
				                    if ($row>0){
                                	    $dbNo = 53; 
                                	    $csnn = 53;
                                	    break;
                                	}
									
									//search ORF Vectors
					                $sql="select * from prodORFVector where LOWER(catNo) like '$catval'";
					                $result=mysql_query($sql,$db);
                                    $row=mysql_num_rows($result);
				                    if ($row>0){
                                	    $dbNo = 54;
                                	    $csnn = 54; 
                                	    break;
                                	}
												
									//search Other Products
									$sql="select * from prodothers where LOWER(catNo) like '$catval'";
									$result=mysql_query($sql,$db);
									$row=mysql_num_rows($result);
									if ($row>0){
										$dbNo = 99;
										break;
									}
							}
							if ($row > 0){
								$r = mysql_fetch_array($result);
											//If Premade siRNA, Adeno or Lenti maintains csn=8
											if($dbNo==12){
												$csnn = $r['csn'];
												if($csn<>23){
													$csnn=56;
												}
											}elseif($dbNo==32){
												$csnn = $r['csn'];
												if($csn<>30){
													$csnn=55;
												}
											}elseif($dbNo<>2&&$dbNo<>3&&$dbNo<>4&&$dbNo<>53&&$dbNo<>54){
                                            	$csnn = $r['csn'];
											}
                                            							$ssnn = $r['ssn'];
                                            							$dsnn = $r['dsn'];
                                            							$pname = $r['pname'];
                                            							$catalog = $r['catNo'];
                                            							$orgprice = $r['price'];
											if($orgprice==0&&$dsnn=12288){
												$genename=str_replace("UTR Lenti-reporter-Luc Vector","",$pname);
												$genename=str_replace("UTR Lenti-reporter-GFP Vector","",$genename);
												$genename=substr_replace($genename,"",-7);
												$srchp = "select * from `3primeUTRsequenceProcess` where geneName like '$genename\n' order by totalNumber desc";
												$resp = mysql_query($srchp,$db);
												$rpr = mysql_fetch_array($resp);
												$orgprice = $rpr['price'];
										    }
                                            $inventory = $r['inventory'];
                                            $supplier = $r['supplier'];
											if (isset($r['size'])){
                                                $size = $r['size'];
                                            }elseif (isset ($r['quantity'])){
                                                $size = $r['quantity'];
                                            }else{
											}
											
												//find discounts for all products for distributors, individual discounts take priority over group discounts and specific discounts take priority over broad category discounts
												$find="select * from distributor_discounts where id_number='$distributor' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='$catalog'";
												$resulting=mysql_query($find,$db);
												$row7=mysql_num_rows($resulting);
												
												$find1="select * from distributor_discounts where id_number='$distributor' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='0'";
												$resulting1=mysql_query($find1,$db);
												$row1=mysql_num_rows($resulting1);
												
												$find2="select * from distributor_discounts where id_number='$distributor' and csn='$csnn' and ssn='$ssnn'and dsn='0' and catNo='0'";
												$resulting2=mysql_query($find2,$db);
												$row2=mysql_num_rows($resulting2);
												
												$find3="select * from distributor_discounts where id_number='$distributor' and csn='$csnn' and ssn='0'and dsn='0' and catNo='0'";
												$resulting3=mysql_query($find3,$db);
												$row3=mysql_num_rows($resulting3);
												
												$find4="select * from distributor_discounts where id_number='$distributor' and csn='0'";
												$resulting4=mysql_query($find4,$db);
												$row4=mysql_num_rows($resulting4);
												
												$find5="select * from distributor_group_discounts where group_number='$grouping' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='$catalog'";
												$resulting5=mysql_query($find5,$db);
												$row5=mysql_num_rows($resulting5);
												
												$find6="select * from distributor_group_discounts where group_number='$grouping' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='0'";
												$resulting6=mysql_query($find6,$db);
												$row6=mysql_num_rows($resulting6);
												
												$find8="select * from distributor_group_discounts where group_number='$grouping' and csn='$csnn' and ssn='$ssnn'and dsn='0' and catNo='0'";
												$resulting8=mysql_query($find8,$db);
												$row8=mysql_num_rows($resulting8);
												
												$find9="select * from distributor_group_discounts where group_number='$grouping' and csn='$csnn' and ssn='0'and dsn='0' and catNo='0'";
												$resulting9=mysql_query($find9,$db);
												$row9=mysql_num_rows($resulting9);
												
												$find10="select * from distributor_group_discounts where group_number='$grouping' and csn='0'";
												$resulting10=mysql_query($find10,$db);
												$row10=mysql_num_rows($resulting10);
												
												$find44="select * from supplier_allowableAccounts where account='$distributor'";
												$resulting44=mysql_query($find44,$db);
												$row44=mysql_num_rows($resulting44);
												if($row44>0 && ($dbNo==1 || $dbNo==8)){
													$find33="select * from supplier_discounts where supplier like '%$supplier%'";
													$resulting33=mysql_query($find33,$db);
													$row33=mysql_num_rows($resulting33);
												}else{
													$row33=0;
												}
												
												if ($row7>0){
													$rf = mysql_fetch_array($resulting);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row5>0){
													$rf = mysql_fetch_array($resulting5);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row1>0){
													$rf = mysql_fetch_array($resulting1);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row6>0){
													$rf = mysql_fetch_array($resulting6);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row2>0){
													$rf = mysql_fetch_array($resulting2);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row8>0){
													$rf = mysql_fetch_array($resulting8);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row3>0){
													$rf = mysql_fetch_array($resulting3);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row9>0){
													$rf = mysql_fetch_array($resulting9);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row4>0){
													$rf = mysql_fetch_array($resulting4);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row10>0){
													$rf = mysql_fetch_array($resulting10);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif ($row33>0){
													$rf = mysql_fetch_array($resulting33);
													$discountper=$rf['percentage_off'];
													$discountamt=$orgprice*$discountper;
													$price=$orgprice-$discountamt;
												}elseif($promoname<>""){
													//For Finding Promotion Code Discounts, only valid if no other discounts found first
													$findpromo1="select * from distributor_promo where promo_code='$promoname' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='$catalog'";
													$resultingpromo1=mysql_query($findpromo1,$db);
													$rowp1=mysql_num_rows($resultingpromo1);
													
													$findpromo2="select * from distributor_promo where promo_code='$promoname' and csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='0'";
													$resultingpromo2=mysql_query($findpromo2,$db);
													$rowp2=mysql_num_rows($resultingpromo2);
													
													$findpromo3="select * from distributor_promo where promo_code='$promoname' and csn='$csnn' and ssn='$ssnn' and dsn='0' and catNo='0'";
													$resultingpromo3=mysql_query($findpromo3,$db);
													$rowp3=mysql_num_rows($resultingpromo3);
													
													$findpromo4="select * from distributor_promo where promo_code='$promoname' and csn='$csnn' and ssn='0' and dsn='0' and catNo='0'";
													$resultingpromo4=mysql_query($findpromo4,$db);
													$rowp4=mysql_num_rows($resultingpromo4);
													
													$findpromo5="select * from distributor_promo where promo_code='$promoname' and csn='0';";
													$resultingpromo5=mysql_query($findpromo5,$db);
													$rowp5=mysql_num_rows($resultingpromo5);
													
													if($rowp1>0){
														$rf = mysql_fetch_array($resultingpromo1);
														$discountper=$rf['percentage_off'];
														$discountamt=$orgprice*$discountper;
														$price=$orgprice-$discountamt;
													}elseif($rowp2>0){
														$rf = mysql_fetch_array($resultingpromo2);
														$discountper=$rf['percentage_off'];
														$discountamt=$orgprice*$discountper;
														$price=$orgprice-$discountamt;
													}elseif($rowp3>0){
														$rf = mysql_fetch_array($resultingpromo3);
														$discountper=$rf['percentage_off'];
														$discountamt=$orgprice*$discountper;
														$price=$orgprice-$discountamt;
													}elseif($rowp4>0){
														$rf = mysql_fetch_array($resultingpromo4);
														$discountper=$rf['percentage_off'];
														$discountamt=$orgprice*$discountper;
														$price=$orgprice-$discountamt;
													}elseif($rowp5>0){
														$rf = mysql_fetch_array($resultingpromo5);
														$discountper=$rf['percentage_off'];
														$discountamt=$orgprice*$discountper;
														$price=$orgprice-$discountamt;
													}else{
														$discountper=0.0;
														$discountamt=0.00;
														$price=$orgprice;
													}
												}else{
													$discountper=0.0;
													$discountamt=0.00;
													$price=$orgprice;
												}
												//Find Shipping Conditions for Product
												$find="select * from distributor_shipping where csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='$catalog'";
												$resulting=mysql_query($find,$db);
												$row7=mysql_num_rows($resulting);
												
												$find1="select * from distributor_shipping where csn='$csnn' and ssn='$ssnn' and dsn='$dsnn' and catNo='0'";
												$resulting1=mysql_query($find1,$db);
												$row1=mysql_num_rows($resulting1);
												
												$find2="select * from distributor_shipping where csn='$csnn' and ssn='$ssnn' and dsn='0' and catNo='0'";
												$resulting2=mysql_query($find2,$db);
												$row2=mysql_num_rows($resulting2);
												
												$find3="select * from distributor_shipping where csn='$csnn' and ssn='0' and dsn='0' and catNo='0'";
												$resulting3=mysql_query($find3,$db);
												$row3=mysql_num_rows($resulting3);
												
												$find4="select * from distributor_shipping where csn='0'";
												$resulting4=mysql_query($find4,$db);
												$row4=mysql_num_rows($resulting4);
												
												if ($row7>0){
													$rf = mysql_fetch_array($resulting);
													$conditions=$rf['conditions'];
												}elseif ($row1>0){
													$rf = mysql_fetch_array($resulting1);
													$conditions=$rf['conditions'];
												}elseif ($row2>0){
													$rf = mysql_fetch_array($resulting2);
													$conditions=$rf['conditions'];
												}elseif ($row3>0){
													$rf = mysql_fetch_array($resulting3);
													$conditions=$rf['conditions'];
												}elseif ($row4>0){
													$rf = mysql_fetch_array($resulting4);
													$conditions=$rf['conditions'];
												}else{
													$conditions='N/A';
												}
                                            
                                        }else{
                                            echo "<script language=javascript>alert('One or more product(s) not found, rest of products added successfully.');</script>";
                                            break;
                                        }
                                        //Insert item into shopping cart
                                        $ins = "insert into shoplist_dist (catNo,csnNumber,ssnNumber,dsnNumber,dbNo,pname,sessionid,unit,org_price,discount_percent,discount_amount,price,quantity,supplier,shipping,inventory) 
                                        values ('$catalog',$csnn,$ssnn,$dsnn,'$dbNo','$pname','$ssid','$size','$orgprice','$discountper','$discountamt','$price','$quanval','$supplier','$conditions','$inventory')";
                                        $ins_res = mysql_query($ins,$db);
						}
				}else{
                                   echo "<script language=javascript>alert('No product selected to add to cart, remember to check the box of the product you want to add to your cart.');</script>";
                                }
          ?>
